package com.lagou.edu.service.impl;

import com.lagou.service.edu.EmailService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

@Component
//homework6 增加动态配置注解
@RefreshScope
//homework12 引入dubbo的service
@Service
public class EmailServiceImpl implements EmailService {

//    @Autowired
//    private JavaMailSender mailSender;
//

    @Value("${spring.mail.test}")
    private String test;

    @Override
    public boolean sendSimpleMail(String to, String subject, String content) {
        try {
            System.out.println("spring.mail.test = "+test);
            //创建SimpleMailMessage对象
//            SimpleMailMessage message = new SimpleMailMessage();
//            //邮件发送人
//            message.setFrom(from);
//            //邮件接收人
//            message.setTo(to);
//            //邮件主题
//            message.setSubject(subject);
//            //邮件内容
//            message.setText(content);
//            //发送邮件
//            mailSender.send(message);
            return true;
        }catch (Exception e) {
            e.printStackTrace();
        }
        return false;

    }
}
